﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TextFile
{
    class Program
    {
        private static string fileName = @"c:\users\администратор.best-6yloygj6vl\documents\visual studio 2012\Projects\TextFile\TextFile\text.txt";

        static void Main(string[] args)
        {
            var getLine = 7;
            var getWord = 4;

            using (var reader = new StreamReader(fileName, Encoding.ASCII))
            {
                int c = 0;
                string word = "";
                int lineNumber = 1, wordNumber = 0;
                while (!reader.EndOfStream)
                {
                    c = reader.Read();
                    if (c == '\r' && (c = reader.Read()) == '\n')
                    {
                        lineNumber++;

                        if (lineNumber == getLine)
                        {
                            word = "";
                            wordNumber = 1;
                            while (!reader.EndOfStream)
                            {
                                c = reader.Read();
                                if (c == '\r' && (c = reader.Read()) == '\n')
                                    break;
                                if (c == '\t' || c == ' ')
                                {
                                    if (wordNumber == getWord)
                                    {
                                        Console.WriteLine(word);
                                        break;
                                    }
                                    if (word.Length > 0)
                                    {
                                        word = "";
                                        wordNumber++;
                                    }
                                    continue;
                                }
                                var ch = (char)c;
                                word += ch.ToString();
                            }
                            break;
                        }
                    }
                }
            }
        }
    }
}
